/**
 * AgaEngine (c)2011.
 * FileName:BaseElement.java
 */
package aga.engine.go;

import java.util.ArrayList;

import aga.engine.AgaCfg;
import aga.engine.listener.OnKeyBoardListener;
import aga.engine.physic.Physic;
import aga.engine.physic.PhysicBody;
import aga.engine.physic.PhysicEngine;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.KeyEvent;

/**
 * 基础游戏物件
 * @author zhe.yangz
 */
public class GameObject implements IAgaDrawable, IAgaTickable, OnKeyBoardListener {
	//===========================================================
	//Constants
	//===========================================================

	//===========================================================
	//Fields
	//===========================================================
	public boolean enabled = true;
	public boolean deleted = false;
	public boolean alwaysShow = false;
	public boolean isPhysicSupport = false;
	public Bitmap mBitmapMain = null;
	
	public ArrayList<Physic> mPhysics = new ArrayList<Physic>();
	protected PhysicEngine pPE = null;
	
	public float mSpeed = 0; //TEMP
	public int mX = 0;
	public int mY = 0;
	public float mAngle = 0;
	
	//===========================================================
	//Constructors
	//===========================================================
	public GameObject(PhysicEngine pe, int x, int y, float angle) {
		if (pe != null) {
			pPE = pe;
			isPhysicSupport = true;
			definePhysics(x*AgaCfg.MAP2PHY_SCALE, y*AgaCfg.MAP2PHY_SCALE, angle);
		}
	}
	//===========================================================
	//Getter & Setter
	//===========================================================

	//===========================================================
	//Methods for/from SuperClass/Interfaces
	//===========================================================

	protected void definePhysics(float x, float y, float angle) {};
	
	public void draw(Canvas canvas) {
		if (mBitmapMain != null)
			canvas.drawBitmap(this.mBitmapMain, this.getX(), this.getY(), null);
	}

	public void tick() {
		
	}
	
	//===========================================================
	//Methods
	//===========================================================

	public float getAngle() {
		return mAngle;
	}
	
	public int getX() {
		return mX;
	}
	
	public int getY() {
		return mY;
	}

	@Override
	public void onKeyDown(int keyCode, KeyEvent event) {
		//default none op
	}

	@Override
	public void onKeyUp(int keyCode, KeyEvent event) {
		//default none op
	}
	
	//===========================================================
	//Inner and Anonymous Classes
	//===========================================================
}
